#!/usr/bin/python
# -*- coding:utf-8 -*-

from cassandra.cluster import Cluster

# 创建数据库键空间
# create keyspace if not exists stock with replication={'class':'SimpleStrategy','replication_factor':1};
# alter keyspace stock with replication={'class':'SimpleStrategy','replication_factor':2}
# desc keyspace stock;
# drop keyspace stock;

# create table users(sid text primary key, name text, age int);
# create table timeline(
#  userid uuid,
#  posted_month int,
#  posted_time uuid,
#  posted_by text,
#  primary key(userid,posted_month,posted_time)
# ) with compaction = {'class':'LeveledCompactionStrategy'}
# desc table users;
#

if __name__ == "__main__":
    cluster = Cluster(['192.168.100.104'])
    session = cluster.connect('stock')
    rows = session.execute("select * from users")
    for row in rows:
        print(row.name)
